package com.xbongbong.pro.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * 阶段推进器-字段编辑与关联字段支持的字段类型
 * @author 李少杰
 * @version v1.0.0
 * @date 2022/1/19 09:40
 */
@Getter
public enum StageConditionsFieldEnum {

    /**
     * 字段编辑与关联字段编辑支持的字段类型
     */
    TEXT(FieldTypeEnum.TEXT),

    TEXTAREA(FieldTypeEnum.TEXTAREA),

    NUM(FieldTypeEnum.NUM),

    DATETIME(FieldTypeEnum.DATETIME),

    LABEL(FieldTypeEnum.LABEL),

    COMBO(FieldTypeEnum.COMBO),

    IMAGE(FieldTypeEnum.IMAGE),

    ADDRESS(FieldTypeEnum.ADDRESS),

    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),

    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),

    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),

    LINK_DATA(FieldTypeEnum.LINK_DATA),

    LINK_DATA_MULTI(FieldTypeEnum.LINK_DATA_MULTI),

    USER(FieldTypeEnum.USER),

    USER_GROUP(FieldTypeEnum.USER_GROUP),

    DEPT(FieldTypeEnum.DEPT),

    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP),

    UPLOAD(FieldTypeEnum.UPLOAD),

    LOCATION(FieldTypeEnum.LOCATION),

    STAR(FieldTypeEnum.STAR),

    RICH_TEXT(FieldTypeEnum.RICH_TEXT),

    MANUAL_SIGN(FieldTypeEnum.MANUAL_SIGN),
    ;

    private final FieldTypeEnum fieldTypeEnum;

    StageConditionsFieldEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }

    public static StageConditionsFieldEnum getByCode(Integer fieldType) {
        for (StageConditionsFieldEnum stageConditionsFieldEnum : values()) {
            if (Objects.equals(stageConditionsFieldEnum.getFieldTypeEnum().getType(), fieldType)) {
                return stageConditionsFieldEnum;
            }
        }
        return null;
    }
}
